#include<iostream>

using namespace std;

char maze[15][15];
bool vis[15][15];
int n, m;
int ant = 0;

void dfs(int x, int y) {
	if (x < 0 || x >= n || y < 0 || y >= m || vis[x][y] || maze[x][y] == '#') {
		return;
	}
	cout << x << ends << y << ends << maze[x][y] << endl;
	if (maze[x][y] == 'T') {
		ant++;
		return;
	}
	vis[x][y] = true;
	dfs(x - 1, y);
	dfs(x, y - 1);
	dfs(x + 1, y);
	dfs(x, y +1);
	vis[x][y] = false;
}

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> maze[i];
	}
	int x, y;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (maze[i][j] == 'S') {
				x = i;
				y = j;
				break;
			}
		}
	}
	dfs(x, y);
	cout << "ant = " << ant << endl;
	return 0;
}
